/// @file Tan.h
#pragma once
#include <boost/noncopyable.hpp>
#include <QPolygonF>
#include <QColor>

namespace qtangram {
/// @class Tan
/// @brief Abstract representation of a Tan. Holds single Tan, its color, current and original shape.
class Tan {
public:
    /// Default constructor.
    Tan() : selected(false), flip(false), angle(0) {}

    /// Constructor
    /// @param QPointF reference reference point
    /// @param QColor background background color
    /// @param QPolygonF original original shape
    Tan(QPointF reference, QColor background, QPolygonF original);

    /// Returns the number of vertexes
    int getLength() const { return polyOriginal.count(); }

    /// Setter for reference point
    /// @param QPointF point reference point
    void setReferencePoint(QPointF point) { refPoint = point; }

    /// Setter for original shape
    /// @param QPolygonF polygon original polygon
    void setOriginalPoly(QPolygonF polygon) { polyOriginal = polygon; }

    /// Setter for current shape
    /// @param QPolygonF polygon current polygon
    void setCurrentPoly(QPolygonF polygon) { polyCurrent = polygon; }


    /// Setter for background color
    /// @param QColor color background color
    void setBackgroundColor(QColor color) { backgroundColor = color; }

    /// Getter for reference point
    /// @return QPointF & reference point
    QPointF & getReferencePoint() { return refPoint; }

    /// Getter for original shape
    /// @return QPolygonF & original polygon
    QPolygonF & getOriginalPoly() { return polyOriginal; }

    /// Getter for current shape
    /// @return QPolygonF & current polygon
    QPolygonF & getCurrentPoly() { return polyCurrent; }

    /// Getter for screen shape
    /// @return QPolygonF & screen polygon

    /// Getter for background color
    /// @return QColor & background color
    QColor & getBackgroundColor() { return backgroundColor; }
    bool operator<(const Tan& tan) const {
        return ID < tan.ID;
    }
    /// Returns to starting position
    void setDefaultPosition();
    /// Regreshes the polygon using te origin point and angle
    void recalculateCurrentPolygon();
    /// True if currently selected
    bool selected;
    /// True if currently flipped
    bool flip;
    /// current angle
    qreal angle;
    /// current screen coordinates
    QPolygonF polyScreen;
    /// current world coordinates
    QPolygonF polyCurrent;
    /// current location
    QPointF currentPoint;
    /// starting point
    QPointF refPoint;
    /// starting polygon
    QPolygonF polyOriginal;
    quint16 ID;
protected:
    QColor backgroundColor;
};
}
